package cn.kgm.makeGodV2.trigger;

import cn.kgm.makeGodV2.GamePlayer;
import cn.kgm.makeGodV2.WorldState;
import lombok.Builder;
import lombok.Data;

/**
 * 性格特性触发器
 *
 * @Version 1.8
 * @Author: Kappi
 * @Date: 2025-9-16 10:31
 * @Description: cn.kgm.makeGodV2.trigger.TraitTrigger
 */
@Data
@Builder
public class TraitTrigger implements EventTrigger {
    private String trait;
    private double minValue;
    private double maxValue;

    public TraitTrigger(String trait, double minValue, double maxValue) {
        this.trait = trait;
        this.minValue = minValue;
        this.maxValue = maxValue;
    }

    @Override
    public boolean checkTrigger(GamePlayer npc, WorldState worldState) {
        double value = getTraitValue(npc, trait);
        return value >= minValue && value <= maxValue;
    }

    private double getTraitValue(GamePlayer npc, String trait) {
        switch (trait) {
            case "openness":
                return npc.getTraits().getOpenness();
            case "conscientiousness":
                return npc.getTraits().getConscientiousness();
            case "extraversion":
                return npc.getTraits().getExtraversion();
            case "agreeableness":
                return npc.getTraits().getAgreeableness();
            case "neuroticism":
                return npc.getTraits().getNeuroticism();
            default:
                return 0;
        }
    }
}
